package com.baibei.pay.recharge;

import android.os.Bundle;
import android.text.TextUtils;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.baibei.basic.IPresenter;
import com.baibei.model.InoutFundParam;
import com.baibei.module.AppRouter;
import com.baibei.module.BasicActivity;
import com.baibei.pay.R;
import com.baibei.widget.Toolbar;
import com.blankj.utilcode.utils.LogUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

@Route(path = AppRouter.ROUTER_INOUTFUND_WEB)
public class InOutFundActivity extends BasicActivity {

    /**
     * 碎片
     */
    private PaymentWebViewFragment mFragment;
    private InoutFundParam mParam;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recharge_web_view);
        mParam = getIntent().getParcelableExtra("param");
        mFragment = PaymentWebViewFragment.newInstance(mParam);
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, mFragment).commitAllowingStateLoss();

        EventBus.getDefault().register(this);

    }


    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        final Toolbar toolbar = (Toolbar) mToolbar;
        toolbar.post(new Runnable() {
            @Override
            public void run() {
                String title = getIntent().getStringExtra("title");
                if (!TextUtils.isEmpty(title)) {
                    toolbar.setTitle(title);
                }
            }
        });
    }

    @Subscribe
    public void onSuccess(SuccessEvent event) {
        //充值成功回调
        finish();
    }


    @Override
    protected void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }

    @Override
    public IPresenter getBasicPresenter() {
        return null;
    }

}
